/**
 * @param {string} s
 * @return {boolean}
 */
 var isValid = function(s) {
    let stack = []
    let map = {
      '(':')',
      '{':'}',
      '[':']'
    }
    for(let i of s){
      if(map[i]){
        stack.push(i)
        continue
      }
      if(map[stack[stack.length - 1]] === i){
        stack.pop()
      }else{
        return false
      }
    }
    return !stack.length
};